package com.ias.agdis_r.manager;

import android.util.Log;

import com.ias.agdis_r.bean.auth.Authority;
import com.ias.agdis_r.bean.fight.FlightQueryValue;
import com.ias.agdis_r.bean.fight.FlightQueryValueChanged;
import com.ias.agdis_r.bean.fight.Query;
import com.ias.agdis_r.bean.fight.QueryParams;
import com.ias.agdis_r.bean.fight.SubFlightInfo;
import com.ias.agdis_r.bean.fight.SubFlightInfos;
import com.ias.agdis_r.bean.message.MessageBean;
import com.ias.agdis_r.bean.message.MessageTemplate;
import com.ias.agdis_r.bean.message.MessageTemplates;
import com.ias.agdis_r.bean.message.SummaryTemplates;
import com.ias.agdis_r.bean.other.AreaBean;
import com.ias.agdis_r.bean.other.GpsInfoBean;
import com.ias.agdis_r.bean.other.IQRYInfoBean;
import com.ias.agdis_r.bean.task.FLG10TaskBean;
import com.ias.agdis_r.bean.task.FLG10TaskInfoBean;
import com.ias.agdis_r.bean.task.SendTaskInfoBean;
import com.ias.agdis_r.bean.task.Task;
import com.ias.agdis_r.bean.task.TaskForward;
import com.ias.agdis_r.bean.task.TaskRefreshBean;
import com.ias.agdis_r.bean.task.TaskServiceLabel;
import com.ias.agdis_r.bean.task.TaskTMRSBean;
import com.ias.agdis_r.bean.user.MemberInfoBean;
import com.ias.agdis_r.bean.user.UserInfoBean;
import com.ias.agdis_r.module.MessageModel;
import com.ias.agdis_r.module.ParameterModel;
import com.ias.agdis_r.terminalmanager.restful.workgroup.vo.WorkGroupLoadMembersResponseVO;
import com.ias.agdis_r.util.S;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;

/**
 * javabean管理类
 * 
 * @author wanghu
 * 
 */
public class JavaBeanManager {

	private static JavaBeanManager instance = null;// 单例的临时javabean数据管理器

	private UserInfoBean userinfo = null;// 登陆员工信息
	private SendTaskInfoBean sendtaskinfo = null;// 转发临时任务信息
	private MemberInfoBean memberinfo = null;// 同组成员信息
	private TaskRefreshBean refreshBean = null; // 下发的TRST
	private TaskTMRSBean refreshTMRSBean = null; // 下发的TMRS
	private IQRYInfoBean IQRYinfo = null;// 临时IQRY信息
	private ArrayList<GpsInfoBean> gpsinfos = null;// GPS数据列表
	private GpsInfoBean lastGpsInfo = null;//最新的GPS数据
	private ArrayList<FlightQueryValueChanged> flightchangeList = null;  //航班变更信息维护列表
	private Authority authority_bean = null;
	private List<Map<String, Object>> mData = new ArrayList<Map<String, Object>>();
	private List<Map<String, Object>> mData_lock = new ArrayList<Map<String, Object>>();
	private SummaryTemplates summaryTemlates = null;
	private List<Query> queryList  = new ArrayList<Query>();
	private List<SubFlightInfo> subFlightList = new ArrayList<SubFlightInfo>();
	private ArrayList<MessageTemplate> msgTempList;						// 短语模板列表
	private ArrayList<HashMap<String, String>> mylist_msgshort = new ArrayList<HashMap<String, String>>();
	private ArrayList<HashMap<String, String>> mylist_msgremind = new ArrayList<HashMap<String, String>>();
	private FLG10TaskInfoBean flg10taskinfo = null;// 临时任务信息
	private String QJMonitorState = "";// 保存清洁监控列表排序过滤条件
	private int selectPos = 0;// 保存清洁监控列表所处的位置
	private List<TaskForward> taskForwardList = new ArrayList<TaskForward>();// 接收已转发任务列表
	private boolean hideTodayFlight = false;
	private String todayFlightTime = "0000";
	private List<AreaBean> placeAreaList = new ArrayList<AreaBean>();
	private List<AreaBean> bltAreaList = new ArrayList<AreaBean>();
	private List<AreaBean> gtnAreaList = new ArrayList<AreaBean>();
	private List<AreaBean> psnAreaList = new ArrayList<AreaBean>();
	private boolean isGridTaskMode = false;
	private int[] isFlightSearchUnlimit = new int[5];
	private boolean initQueryLuggage = false;
	private WorkGroupLoadMembersResponseVO workGroupLoadInfo;		// 班组信息

	public WorkGroupLoadMembersResponseVO getWorkGroupLoadInfo() {
		return workGroupLoadInfo;
	}

	public void setWorkGroupLoadInfo(WorkGroupLoadMembersResponseVO workGroupLoadInfo) {
		this.workGroupLoadInfo = workGroupLoadInfo;
	}

	public void setGridTaskMode() {
		isGridTaskMode = DataBaseManager.getInstance().getBoolean(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.TASK_GRIDVIEW);
	}

	public boolean isGridTaskMode() {
		return isGridTaskMode;
	}

	public void setFlightSearchUnlimit() {
		isFlightSearchUnlimit[0] = DataBaseManager.getInstance().getInt(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.FLIGHT_SEARCH_UNLIMIT_FLN);
		isFlightSearchUnlimit[1] = DataBaseManager.getInstance().getInt(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.FLIGHT_SEARCH_UNLIMIT_REG);
		isFlightSearchUnlimit[2] = DataBaseManager.getInstance().getInt(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.FLIGHT_SEARCH_UNLIMIT_PSN);
		isFlightSearchUnlimit[3] = DataBaseManager.getInstance().getInt(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.FLIGHT_SEARCH_UNLIMIT_BLT);
		isFlightSearchUnlimit[4] = DataBaseManager.getInstance().getInt(ParameterModel.T_TASK_GRIDVIEW_MODE, ParameterModel.FLIGHT_SEARCH_UNLIMIT_GAT);
	}

	public int[] getFlightSearchUnlimit() {
		return isFlightSearchUnlimit;
	}

	public boolean isInitQueryLuggage() {
		return initQueryLuggage;
	}

	public void setInitQueryLuggage(boolean initQueryLuggage) {
		this.initQueryLuggage = initQueryLuggage;
	}

	public boolean isHideTodayFlight() {
		return hideTodayFlight;
	}

	public void setHideTodayFlight() {
		this.hideTodayFlight = DataBaseManager.getInstance().getBoolean(ParameterModel.T_FLIGHT_INFO, ParameterModel.HIDE_TODAY_FLIGHT);
	}

	public String getTodayFlightTime() {
		return todayFlightTime;
	}

	public void setTodayFlightTime() {
		this.todayFlightTime = DataBaseManager.getInstance().getString(ParameterModel.T_FLIGHT_INFO, ParameterModel.TODAY_FLIGHT_TIME);
	}

	public List<AreaBean> getPlaceAreaList() {
		return placeAreaList;
	}

	public List<AreaBean> getPsnAreaList() {
		return psnAreaList;
	}

	public List<AreaBean> getBltAreaList() {
		return bltAreaList;
	}

	public List<AreaBean> getGtnAreaList() {
		return gtnAreaList;
	}

	public List<TaskForward> getTaskForwardList() {
		return taskForwardList;
	}

	public void setTaskForwardList(List<TaskForward> taskForwardList) {
		this.taskForwardList = taskForwardList;
	}
	public void deleteTaskForwardList() {
		taskForwardList.clear();
	}
	public int getSelectPos() {
		return selectPos;
	}

	public void setSelectPos(int selectPos) {
		this.selectPos = selectPos;
	}

	public String getQJMonitorState() {
		return QJMonitorState != null ? QJMonitorState : "";
	}

	public void saveQJMonitorState(String state){
		QJMonitorState = state;
	}

	public void deleteQJMonitorState(){
		QJMonitorState = null;
	}

	public List<Map<String, Object>> getSubDate(){
		return mData;
	}
	
	public List<Map<String, Object>> getLockData(){
		return mData_lock;
	}
	
	public List<Query> getQueryList() {
		return queryList;
	}
	
	public void cleanQueryList() {
		if (queryList != null) {
			queryList.clear();
		}
	}

	public void addQueryItem(QueryParams info) {
		if (info == null || info.getQueryParams() == null) {
			return;
		}
		this.queryList.addAll(info.getQueryParams());
	}
	
	public SummaryTemplates getSummaryTemplates(){
		if(null == summaryTemlates){
			summaryTemlates = DataBaseManager.getInstance().readSummaryMsg();
		}
		return summaryTemlates;
	}

	public ArrayList<MessageTemplate> getMsgTempList() {
		return msgTempList;
	}

	public void saveMSGTemplate(MessageTemplates msgTemplates)
	{
		msgTempList = new ArrayList<>();
		if (msgTemplates != null && msgTemplates.getMessagetemplates() != null) {
			msgTempList.addAll(msgTemplates.getMessagetemplates());
		}
	}

	public void loadMSGTemplate()
	{
		// 如果模板全部下载成功，将短语模板进行分类
		buildMSG();
		if (msgTempList != null) {
			msgTempList.clear();
		}
	}
	
	public void clearMSGTemplate()
	{
		if (msgTempList != null) {
			msgTempList.clear();
			msgTempList = null;
		}
		mylist_msgshort.clear();
		mylist_msgremind.clear();
	}
	
	public ArrayList<HashMap<String, String>> getMSGShort(){
		return mylist_msgshort;
	}
	
	public ArrayList<HashMap<String, String>> getMSGRemind(){
		return mylist_msgremind;
	}

	public void buildMSG() {
		if (msgTempList == null) {
			return;
		}
		for (MessageTemplate msgTemp : msgTempList) {
			HashMap<String, String> map = new HashMap<String, String>();
			map.put(MessageModel.ID, msgTemp.getId());
			map.put(MessageModel.CTNT, msgTemp.getTxt());
			map.put(MessageModel.ADID, msgTemp.getAod());
			map.put(MessageModel.IFTK, msgTemp.getFlag());
			map.put(MessageModel.PCID, msgTemp.getPid());
			map.put(MessageModel.SENM, msgTemp.getSenm());

			if (msgTemp.getPid() != null && msgTemp.getFlag() != null) {
				if (msgTemp.getFlag().trim().equals("R") && !msgTemp.getPid().trim().equals("")) {
					mylist_msgremind.add(map);
				} else {
					mylist_msgshort.add(map);
				}
			} else {
				mylist_msgshort.add(map);
			}
		}
	}
	
	/**
	 * 单例模式
	 * @return
	 */
	public static JavaBeanManager getInstance() {
		if (instance == null) {
			instance = new JavaBeanManager();
		}
		return instance;
	}

	public UserInfoBean getUserinfo() {
		if (userinfo == null) {
			userinfo = new UserInfoBean();
		}
		return userinfo;
	}
	
	//add by huzedong for temp auth
	public Authority getAuthority() {
		if(null == authority_bean){
			authority_bean = new Authority();
		}
		return authority_bean;
	}
	public void setAuthority(Authority auth) {
		authority_bean = auth;
	}
	public boolean adjust_pri(String pri) {
		// 未登录时authority_bean为空
		if (authority_bean == null) {
			return false;
		} else {
			List<String> list = authority_bean.getAuthres();
			int length = list.size();
			boolean cv = false;
			for (int i = 0; i < length; i++) {
				cv = list.contains(pri);
				if (cv) {
					return cv;
				}
			}
			return cv;
		}
	}
	public String adjust_p(){
		if(authority_bean != null){
			return authority_bean.getPtype();
		} else {
			return null;
		}
	}
	/**
	 * 保存登陆信息
	 * 
	 * @param userinfo
	 */
	public void saveUserLoginData(UserInfoBean userinfo) {
		this.userinfo = userinfo;
	}

	/**
	 * 删除登陆信息
	 */
	public void deleteUserLoginData() {
		userinfo=null;
	}

	public void deleteEnb() {
		if (userinfo != null) {
			userinfo.setEnb(null);
		}
	}

	/**
	 * 保存同组成员信息
	 * 
	 * @param info
	 */
	public void saveMemberListData(HashMap<Object, Object> info) {
		if (info != null) {
			if (memberinfo == null)
				memberinfo = new MemberInfoBean();

			memberinfo.setMemberlist(S.valueOf(info.get(ParameterModel.MEMBER_LIST)));
		}
	}
	
	/**
	 * 保存ITMD信息
	 * @author zhangsc
	 * @param orgTask
	 */
	public void saveITMDData(Task orgTask) {
		LinkedHashMap<String, TaskServiceLabel> serviceLabel = (LinkedHashMap<String, TaskServiceLabel>) orgTask.getServiceLabelMap();
		if(serviceLabel == null){
			return;
		}
		Task task = DataManager.getInstance().getWorkTask(orgTask.getTNB());	
		
		if (task != null) {
			LinkedHashMap<String, TaskServiceLabel> tmp = (LinkedHashMap<String, TaskServiceLabel>) task.getServiceLabelMap();
			if (tmp.size() == 0) {
				tmp.putAll(serviceLabel);
			} else {
				task.setServiceLabelMap(serviceLabel);
			}
		}
	}
	
	/**
	 * 删除同组成员信息
	 */
	public void deleteMemberListData() {
		if (memberinfo != null)
			memberinfo.setMemberlist(null);
	}
	

	public void deleteRelativeTask(Task task){
		
		if(null!=task&&null!=task.getTaskInfo().getFKE())
		{
		
			String fke = task.getTaskInfo().getFKE();
			if(S.isEmpty(fke))
			{
				return;
			}
			
			LinkedHashMap<String, MessageBean> isreadMsgList = DataManager.getInstance().getIsreadMsgList();
			LinkedHashMap<String, MessageBean> unreadMsgList = DataManager.getInstance().getUnreadMsgList();
			//删除已读短语列表中的短语
			ListIterator<Map.Entry<String, MessageBean>> sss1 = new ArrayList<Map.Entry<String, MessageBean>>(
					isreadMsgList.entrySet()).listIterator(isreadMsgList.size());
			while (sss1.hasPrevious()) 
			{
				Map.Entry<String, MessageBean> entry = sss1.previous();	
				MessageBean msgBean = entry.getValue();
				if(msgBean.getFKE().equals(fke))
				{
					isreadMsgList.remove(msgBean.getTGN());
				}	
			}
			//删除未读短语列表中的短语
			ListIterator<Map.Entry<String, MessageBean>> sss2 = new ArrayList<Map.Entry<String, MessageBean>>(
					unreadMsgList.entrySet()).listIterator(unreadMsgList.size());
			while (sss2.hasPrevious()) 
			{
				Map.Entry<String, MessageBean> entry = sss2.previous();	
				MessageBean msgBean = entry.getValue();
				if(msgBean.getFKE().equals(fke))
				{
					unreadMsgList.remove(msgBean.getTGN());
				}	
			}
		}
	}

	public void saveGTFLInfo(String _GTFL){
		if (IQRYinfo == null)
			IQRYinfo = new IQRYInfoBean();
		IQRYinfo.setGTFL(_GTFL);
	}
	public void saveFLG4Info(String _sIdx) {
		if (IQRYinfo == null)
			IQRYinfo = new IQRYInfoBean();
		IQRYinfo.setIdxFlg4(_sIdx);
	}
	public void saveFLG3Info(String _sIdx) {
		if (IQRYinfo == null)
			IQRYinfo = new IQRYInfoBean();
		IQRYinfo.setIdxFlg3(_sIdx);
	}
	public void saveFLG10IdxInfo(String _sIdx){
		if (IQRYinfo == null)
			IQRYinfo = new IQRYInfoBean();
		IQRYinfo.setIDXFLG10(_sIdx);
	}
	public void saveFLG10SdxInfo(String _sSdx){
		if (IQRYinfo == null)
			IQRYinfo = new IQRYInfoBean();
		IQRYinfo.setSDXFLG10(_sSdx);
	}
	/**
	 * 删除IQRY信息
	 */
	public void deleteIQRYData() {
		if (IQRYinfo != null) {
			IQRYinfo.setIdxFlg3(null);
			IQRYinfo.setIdxFlg4(null);
			IQRYinfo.setIDXFLG10(null);
			IQRYinfo.setSDXFLG10(null);
			IQRYinfo.setGTFL(null);
		}
	}

	/**
	 * 保存GPS信息（1秒保存一次）
	 * 
	 * @param info
	 * @param bUpload:是否上传到服务器
	 */
	public void saveGpsData(HashMap<Object, Object> info, boolean bUpload) {
		if (info == null) {
			return;
		}
		if (gpsinfos == null) {
			gpsinfos = new ArrayList<GpsInfoBean>();
		}

		GpsInfoBean tmp = new GpsInfoBean();
		tmp.setBear(info.get(ParameterModel.GPS_BEAR).toString());
		tmp.setGpsSpeed(Float.parseFloat(info.get(ParameterModel.GPS_SPEED).toString()));
		tmp.setGpsTime(info.get(ParameterModel.GPS_TIME).toString());
		tmp.setLatitude(info.get(ParameterModel.GPS_LATITUDE).toString());
		tmp.setLongitude(info.get(ParameterModel.GPS_LONGITUDE).toString());
		lastGpsInfo = tmp;

		if (!bUpload) {
			return;
		}

		if (!gpsinfos.isEmpty()) {
			// 新坐标如果位置没变则不收集
			GpsInfoBean lastGps = gpsinfos.get(gpsinfos.size() - 1);
			if (lastGps.getLongitude().equals(tmp.getLongitude()) && lastGps.getLatitude().equals(tmp.getLatitude())) {
				return;
			}
		}

		gpsinfos.add(tmp);
		Log.i(this.toString(), "gpsinfos size: " + gpsinfos.size());
	}

	/**
	 * 删除Gps信息（注销时）
	 */
	public void deleteGpsData() {
		if (gpsinfos != null) {
			gpsinfos.clear();
		}
		if (lastGpsInfo != null) {
			lastGpsInfo = null;
		}
	}

	public FLG10TaskInfoBean getFLG10Taskinfo() {
		if (flg10taskinfo == null) {
			flg10taskinfo = new FLG10TaskInfoBean();
		}
		if (flg10taskinfo.getList() == null){
			ArrayList<FLG10TaskBean> getList = new ArrayList<FLG10TaskBean>();
			flg10taskinfo.setList(getList);
		}
		return flg10taskinfo;
	}

	public ArrayList<FLG10TaskBean> getFiltedList(String method, String value)
			throws Exception {
		ArrayList<FLG10TaskBean> list = new ArrayList<FLG10TaskBean>();
		if (null == getFLG10Taskinfo().getList()) {
			return list;
		} else {
			list.addAll(getFLG10Taskinfo().getList());
			if ("getFln".equals(method)) {
				return filteList(list, method, value);
			} else if ("getReg".equals(method)) {
				return filteList(list, method, value);
			} else if ("getPsn".equals(method)) {
				return filteList(list, method, value);
			} else if ("getTst".equals(method)) {
				return filteList(list, method, value);
			} else {
				return list;
			}
		}
	}

	private ArrayList<FLG10TaskBean> filteList(ArrayList<FLG10TaskBean> list,
											   String method, String value) throws Exception {
		ArrayList<FLG10TaskBean> newList = new ArrayList<FLG10TaskBean>();
		final Method m1 = new FLG10TaskBean().getClass().getMethod(method);
		for (FLG10TaskBean flg10Task : list) {
			String value1 = (String) m1.invoke(flg10Task);
			if (null == value1) {
				value1 = "";
			}
			value1.toUpperCase();
			String value2 = value.toUpperCase();
			if (value1.contains(value2)) {
				newList.add(flg10Task);
			}
		}
		// 此处不进行排序，数据默认按时间排列
//		Collections.sort(newList, new Comparator<FLG10TaskBean>() {
//			@Override
//			public int compare(FLG10TaskBean task1, FLG10TaskBean task2) {
//				int ret = 0;
//				try {
//					ret = m1.invoke(task1).toString()
//							.compareTo(m1.invoke(task2).toString());
//				} catch (Exception e) {
//					e.printStackTrace();
//				}
//				return ret;
//			}
//		});
		return newList;
	}

	/**
	 * 保存临时FLG10任务信息
	 *
	 */
	public void saveFLG10TaskData(FLG10TaskBean flg10Task) {
		if (flg10Task != null) {
			if (flg10taskinfo == null)
				flg10taskinfo = new FLG10TaskInfoBean();
			if (flg10taskinfo.getList() == null)
				flg10taskinfo.setList(new ArrayList<FLG10TaskBean>());
			flg10taskinfo.getList().add(flg10Task);
			flg10taskinfo.setNewnum(flg10taskinfo.getNewnum() + 1);
		}
	}

	public void deleteFLG10TaskListLinshiData() {
		if (flg10taskinfo != null) {
			flg10taskinfo.setList(null);
		}
	}

	public SendTaskInfoBean getSendTaskinfo() {
		if (sendtaskinfo == null) {
			sendtaskinfo = new SendTaskInfoBean();
		}
		return sendtaskinfo;
	}

	public MemberInfoBean getMemberinfo() {
		return memberinfo;
	}

	public IQRYInfoBean getIQRYinfo() {
		if (IQRYinfo == null) {
			IQRYinfo = new IQRYInfoBean();
		}
		return IQRYinfo;
	}

	public ArrayList<GpsInfoBean> getGpsArrayList() {
		return gpsinfos;
	}
	
	public void clearArrayList() {
		if (gpsinfos != null) {
			gpsinfos.clear();
		}
	}
	
	public GpsInfoBean getLastGpsInfo() {
		return lastGpsInfo;
	}
	
    //add by huzedong 
	public ArrayList<FlightQueryValueChanged> getFlightchangeList() {
		if(null == flightchangeList){
			flightchangeList = new ArrayList<FlightQueryValueChanged>();
		}
		return flightchangeList;
	}
	
	public void removeFlightchange(String fke) {
		
		if (flightchangeList == null){
			return;
		}
		//判断航班变更列表里是否已经有当前的航班号
		for(int i = 0; i < flightchangeList.size(); i++){
			String changefke = flightchangeList.get(i).getFlightQueryValue().getFKE();
			//如果有此航班号
			if(fke.equals(changefke)){
				//删除该航班变更的信息
				flightchangeList.remove(flightchangeList.get(i));
				break;
			}
		}	
	}
	/**
	 * 获取航班变更消息
	 * @param fke
	 */
	public FlightQueryValueChanged getFlightchange(String fke)
	{
		FlightQueryValueChanged queryValueChanged = null;
		if (flightchangeList != null){
			
			//判断航班变更列表里是否已经有当前的航班号
			for(int i = 0; i < flightchangeList.size(); i++){
				String changefke = flightchangeList.get(i).getFlightQueryValue().getFKE();
				//如果有此航班号
				if(fke.equals(changefke)){
					//删除该航班变更的信息
					queryValueChanged =  flightchangeList.get(i);
				}
			}	
		}
		return queryValueChanged;
	}
	/**
	 * 保存航班信息到历史记录里
	 * @param info
	 */
	public void addFlightchange(FlightQueryValueChanged info) {
		if(null == flightchangeList){
			flightchangeList = new ArrayList<FlightQueryValueChanged>();
		}
		String fke = info.getFlightQueryValue().getFKE();

		FlightQueryValueChanged oldFlightChangeValue = null;
		for(int i = 0; i < flightchangeList.size(); i++){
			String changefke = flightchangeList.get(i).getFlightQueryValue().getFKE();
			if(fke.equals(changefke)){			
				oldFlightChangeValue = flightchangeList.get(i);
				break;
			}
		}	
		//如果此航班已经接收到变更消息，修改保存的航班变更对象的值	
		if(oldFlightChangeValue!=null)
		{
			FlightQueryValue newFlightValue = info.getFlightQueryValue();
			//保存变更的MSG内容
			oldFlightChangeValue.setMsg(info.getMsg());
			Field[] newfields = newFlightValue.getClass().getDeclaredFields();
			//遍历新的航班信息
			for(Field field:newfields)
			{
				field.setAccessible(true); 
				try {		
					//如果新的航班内容该项不为空
					if(field.get(newFlightValue)!=null)
					{
						String value = (String) field.get(newFlightValue);
						Field oldField = oldFlightChangeValue.getFlightQueryValue().getClass().getDeclaredField(field.getName());
						//将新的航班信息内容保存到旧的航班信息内容里
						oldField.setAccessible(true);
						oldField.set(oldFlightChangeValue.getFlightQueryValue(),value);
					}
					
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (IllegalAccessException e) {
					e.printStackTrace();
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (NoSuchFieldException e) {
					e.printStackTrace();
				}
			}
		}
		else
		{
			flightchangeList.add(info);
		}
		
	}
	
	public List<SubFlightInfo> getSUBFlightList()
	{
		return subFlightList;
	}
	
	public void clearSUBFlightList()
	{
		if(subFlightList!=null)
		{
			subFlightList.clear();
		}
	}

	public void saveSUBFlight(SubFlightInfos infosBean) {
		
		if(infosBean == null)
		{
			return;
		}
		for(SubFlightInfo info:infosBean.getSubflightinfos())
		{
			subFlightList.add(info);
		}
	}  
	

	public TaskRefreshBean getRefreshBean() {
		if (refreshBean == null){
			refreshBean = new TaskRefreshBean();
		}
		return refreshBean;
	}
	
	public TaskTMRSBean getTRMSBean() {
		if (refreshTMRSBean == null){
			refreshTMRSBean = new TaskTMRSBean();
		}
		return refreshTMRSBean;
	}

	public void setRefreshBean(TaskTMRSBean refreshTMRSBean) {
		this.refreshTMRSBean = refreshTMRSBean;
	}

	public List<FLG10TaskBean> deleteEndTask(List<FLG10TaskBean> delList){
		List<FLG10TaskBean> mDelList = new ArrayList<FLG10TaskBean>();
		if (null == delList){
			return mDelList;
		}
		mDelList.addAll(delList);
		for (int i = 0; i < mDelList.size(); i++) {
			FLG10TaskBean fTask = mDelList.get(i);
			if (MessageModel.TCXX.equals(fTask.getPid())
					|| MessageModel.TRJT.equals(fTask.getPid())
					|| MessageModel.TEND.equals(fTask.getPid())
					|| MessageModel.T_QJHS_YQ.equals(fTask.getPid())
					|| MessageModel.TTRN.equals(fTask.getPid())) {
				mDelList.remove(fTask);
				i--;
			}
		}
		return mDelList;
	}
}
